<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/12/14
 * Time: 10:10
 */

include_once 'DbTools.php';


//连接数据库
DbTools::InitDb();

//获取转入金额
session_start();
$moneyIn = $_POST['moneyIn'];

$money = $_POST['moneyNow'];

echo $moneyIn.','.$money;
$userInfo = $_SESSION[$_COOKIE['Token']];
$cardId = $userInfo['CardId'];

//
//echo $cardId.'<br />';
//echo $money;

$sql = "update bankcard set CardMoney = CardMoney+'$moneyIn' where CardId = '$cardId'";
$result = DbTools::noSelect($sql);
echo $result['status'];
$backUrl = '../user/userInfo.php';
//关闭连接
DbTools::close();
?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>

<input type="hidden" id = 'temp' value=" <?php echo $backUrl;?>">

</body>
<script>
    var backUrl = document.getElementById('temp').value;
    <?php if ($result['status']=='true'): ?>
    alert('存入成功');
    location.href = backUrl
    <?php endif; ?>
</script>
</html>
